<div class="box1">
    <input type="text">
    <ul></ul>
</div>
<script src="./axios.js"></script>
<script>

let iptObj=document.querySelector('.box1 input')
iptObj.oninput = function() {
    let inputdata = document.querySelector('.box1 input').value
    get('http://www.baidu.com/sugrec',`prod=pc&wd=${inputdata}`, res => {})
    .then(
        res=>{
            let ulObj=document.querySelector('.box1 ul')
            ulObj.innerText=''
            if(res.g){
                res.g.forEach(item=>{
                    let liObj=document.createElement('li')
                    liObj.innerText=item.q
                    ulObj.appendChild(liObj)
                })
            }
        })
        .catch(
            err=>{
                console.log(err)
            }
        )
}


</script>
<hr>

<div class="box2">
    <h1>最新电影</h1>
    <button>获取</button>
    <ul></ul>
</div>
<script src="./axios.js"></script>
<script>
let btnObj = document.querySelector('.box2 button')
console.log(btnObj);

btnObj.onclick = function(){
    get('https://m.maizuo.com/gateway',`cityId=210300&pageNum=1&pageSize=10&type=1&k=8134043`,(xhr) => {
        xhr.setRequestHeader('X-Client-Info', '{"a":"3000","ch":"1002","v":"5.0.4","e":"1640005088441707321622529","bc":"310100"}')
        xhr.setRequestHeader('X-Host', 'mall.film-ticket.film.list')
        xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest')
    })
    .then(
        res=> {
        let ulObj = document.querySelector('.box2 ul')
        ulObj.innerHTML = ''
        if(!Array.isArray(res.data.films)) return
        res.data.films.forEach(item => {
            let liObj = document.createElement('li')
            liObj.innerHTML = `
                ${item.flimId}-
                ${item.name}
                <img src="${item.poster}"/>
            `
            ulObj.appendChild(liObj)
        })
    })
    .catch(
            err=>{
                console.log(err)
            }
        )
}


</script>